package com.sf.bank.component;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * 使用redis之后如果改某个包名，必须清redis缓存，药不然报错很奇怪，总报你已经被改名的类不存在
 */
@Component
public class MyApplicationRunner implements ApplicationRunner {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
//    @Override
    public void run(ApplicationArguments args) throws Exception {
        Set<String> keys = stringRedisTemplate.keys("*");
        stringRedisTemplate.delete(keys);
        System.out.println("缓存清除了");
    }
}
